package com.jzsm.modules.sender.controller;

import com.jzsm.modules.sender.holder.PushHolder;
import com.jzsm.modules.sender.vo.MessageVo;
import com.jzsm.common.core.domain.AjaxResult;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@AllArgsConstructor
@RequestMapping("message")
public class PushController {
    final PushHolder pushHolder;

    @PostMapping("push")
    public AjaxResult<String> pushMessage(@RequestBody MessageVo vo) {
        return AjaxResult.success(pushHolder.pushToChannel(vo.getChannelType(), vo.getMessage()));
    }

    @PostMapping("update")
    public AjaxResult<String> updateMessage(@RequestBody MessageVo vo) {
        return AjaxResult.success(null, null);
    }

    @PostMapping("recall")
    public AjaxResult<String> recallMessage(@RequestBody MessageVo vo) {
        return AjaxResult.success(pushHolder.recallMessage(vo.getChannelType(), vo.getMessage()));
    }
}
